home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / TextServices.p < prev    next >
Encoding:
Text File  |  1995-07-06  |  12.7 KB  |  380 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        TextServices.p
  3.  
  4.      Contains:    Text Services Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT TextServices;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __TEXTSERVICES__}
  30. {$SETC __TEXTSERVICES__ := 1}
  31.  
  32. {$I+}
  33. {$SETC TextServicesIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __EVENTS__}
  43. {$I Events.p}
  44. {$ENDC}
  45. {    Quickdraw.p                                                    }
  46. {        MixedMode.p                                                }
  47. {        QuickdrawText.p                                            }
  48. {    OSUtils.p                                                    }
  49. {        Memory.p                                                }
  50.  
  51. {$IFC UNDEFINED __MENUS__}
  52. {$I Menus.p}
  53. {$ENDC}
  54.  
  55. {$IFC UNDEFINED __APPLEEVENTS__}
  56. {$I AppleEvents.p}
  57. {$ENDC}
  58. {    Errors.p                                                    }
  59. {    EPPC.p                                                        }
  60. {        AppleTalk.p                                                }
  61. {        Files.p                                                    }
  62. {            Finder.p                                            }
  63. {        PPCToolbox.p                                            }
  64. {        Processes.p                                                }
  65. {    Notification.p                                                }
  66.  
  67. {$IFC UNDEFINED __ERRORS__}
  68. {$I Errors.p}
  69. {$ENDC}
  70.  
  71. {$IFC UNDEFINED __COMPONENTS__}
  72. {$I Components.p}
  73. {$ENDC}
  74.  
  75. {$PUSH}
  76. {$ALIGN MAC68K}
  77. {$LibExport+}
  78.  
  79. CONST
  80.     kTSMVersion                    = $200;                            { Version of the Text Services Manager is 2.0  }
  81.     kTextService                = 'tsvc';                        { component type for the component description }
  82.     kInputMethodService            = 'inpm';                        { component subtype for the component description }
  83. { Component Flags in ComponentDescription }
  84.     bTakeActiveEvent            = 15;                            { bit set if the component takes active event }
  85.     bHandleAERecording            = 16;                            { bit set if the component takes care of recording Apple Events <new in vers2.0> }
  86.     bScriptMask                    = $00007F00;                    { bit 8 - 14 }
  87.     bLanguageMask                = $000000FF;                    { bit 0 - 7  }
  88.     bScriptLanguageMask            = bScriptMask + bLanguageMask;    { bit 0 - 14  }
  89.  
  90. { Hilite styles }
  91.     kCaretPosition                = 1;                            { specify caret position }
  92.     kRawText                    = 2;                            { specify range of raw text }
  93.     kSelectedRawText            = 3;                            { specify range of selected raw text }
  94.     kConvertedText                = 4;                            { specify range of converted text }
  95.     kSelectedConvertedText        = 5;                            { specify range of selected converted text }
  96.  
  97. { Apple Event constants }
  98. { Event class }
  99.     kTextServiceClass            = kTextService;
  100. { event ID }
  101.     kUpdateActiveInputArea        = 'updt';                        { update the active Inline area }
  102.     kPos2Offset                    = 'p2st';                        { converting global coordinates to char position }
  103.     kOffset2Pos                    = 'st2p';                        { converting char position to global coordinates }
  104.     kShowHideInputWindow        = 'shiw';                        { show or hide the input window }
  105. { Event keywords }
  106.     keyAETSMDocumentRefcon        = 'refc';                        { TSM document refcon, typeLongInteger }
  107. { Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize
  108.     typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to 
  109.     AERegistry.h }
  110.     keyAEServerInstance            = 'srvi';                        { component instance }
  111.     keyAETheData                = 'kdat';                        { typeText }
  112.     keyAEFixLength                = 'fixl';                        { fix len ?? }
  113.     keyAEHiliteRange            = 'hrng';                        { hilite range array }
  114.     keyAEUpdateRange            = 'udng';                        { update range array }
  115.     keyAEClauseOffsets            = 'clau';                        { Clause Offsets array }
  116.     keyAECurrentPoint            = 'cpos';                        { current point }
  117.     keyAEDragging                = 'bool';                        { dragging falg }
  118.     keyAEOffset                    = 'ofst';                        { offset }
  119.     keyAERegionClass            = 'rgnc';                        { region class }
  120.     keyAEPoint                    = 'gpos';                        { current point }
  121.     keyAEBufferSize                = 'buff';                        { buffer size to get the text }
  122.     keyAEMoveView                = 'mvvw';                        { move view flag }
  123.     keyAELength                    = 'leng';                        { length }
  124.     keyAENextBody                = 'nxbd';                        { next or previous body }
  125. { optional keywords for Offset2Pos (Info about the active input area) }
  126.     keyAETextLineHeight            = 'ktlh';                        { typeShortInteger }
  127.     keyAETextLineAscent            = 'ktas';                        { typeShortInteger }
  128. { optional keywords for Pos2Offset }
  129.     keyAELeftSide                = 'klef';                        { type Boolean }
  130. { optional keywords for kShowHideInputWindow }
  131.     keyAEShowHideInputWindow    = 'shiw';                        { type Boolean }
  132. { for PinRange  }
  133.     keyAEPinRange                = 'pnrg';
  134. { Desc type ... }
  135.     typeComponentInstance        = 'cmpi';                        { server instance }
  136.     typeTextRangeArray            = 'tray';                        { text range array }
  137.     typeOffsetArray                = 'ofay';                        { offset array }
  138.     typeText                    = typeChar;                        { Plain text }
  139.     typeTextRange                = 'txrn';
  140.  
  141. { Desc type constants }
  142.     kTSMOutsideOfBody            = 1;
  143.     kTSMInsideOfBody            = 2;
  144.     kTSMInsideOfActiveInputArea    = 3;
  145.  
  146.     kNextBody                    = 1;
  147.     kPreviousBody                = 2;
  148.  
  149. { Low level routines which are dispatched directly to the Component Manager }
  150.     kCMGetScriptLangSupport        = $0001;                        { Component Manager call selector 1 }
  151.     kCMInitiateTextService        = $0002;                        { Component Manager call selector 2 }
  152.     kCMTerminateTextService        = $0003;                        { Component Manager call selector 3 }
  153.     kCMActivateTextService        = $0004;                        { Component Manager call selector 4 }
  154.     kCMDeactivateTextService    = $0005;                        { Component Manager call selector 5 }
  155.     kCMTextServiceEvent            = $0006;                        { Component Manager call selector 6 }
  156.     kCMGetTextServiceMenu        = $0007;                        { Component Manager call selector 7 }
  157.     kCMTextServiceMenuSelect    = $0008;                        { Component Manager call selector 8 }
  158.     kCMFixTextService            = $0009;                        { Component Manager call selector 9 }
  159.     kCMSetTextServiceCursor        = $000A;                        { Component Manager call selector 10 }
  160.     kCMHidePaletteWindows        = $000B;                        { Component Manager call selector 11 }
  161.  
  162. { typeTextRange         'txrn' }
  163.  
  164. TYPE
  165.     TextRange = RECORD
  166.         fStart:                    LONGINT;
  167.         fEnd:                    LONGINT;
  168.         fHiliteStyle:            INTEGER;
  169.     END;
  170.  
  171.     TextRangePtr = ^TextRange;
  172.  
  173.     TextRangeHandle = ^TextRangePtr;
  174.  
  175. { typeTextRangeArray    'txra' }
  176.     TextRangeArray = RECORD
  177.         fNumOfRanges:            INTEGER;                                { specify the size of the fRange array }
  178.         fRange:                    ARRAY [0..0] OF TextRange;                { when fNumOfRanges > 1, the size of this array has to be calculated }
  179.     END;
  180.  
  181.     TextRangeArrayPtr = ^TextRangeArray;
  182.  
  183.     TextRangeArrayHandle = ^TextRangeArrayPtr;
  184.  
  185. { typeOffsetArray        'offa' }
  186.     OffsetArray = RECORD
  187.         fNumOfOffsets:            INTEGER;                                { specify the size of the fOffset array }
  188.         fOffset:                ARRAY [0..0] OF LONGINT;                { when fNumOfOffsets > 1, the size of this array has to be calculated }
  189.     END;
  190.  
  191.     OffsetArrayPtr = ^OffsetArray;
  192.  
  193.     OffsetArrayHandle = ^OffsetArrayPtr;
  194.  
  195.     TSMDocumentID = Ptr;
  196.  
  197.     InterfaceTypeList = ARRAY [0..0] OF OSType;
  198.  
  199. { Text Service Info List }
  200.     TextServiceInfo = RECORD
  201.         fComponent:                Component;
  202.         fItemName:                Str255;
  203.     END;
  204.  
  205.     TextServiceInfoPtr = ^TextServiceInfo;
  206.  
  207.     TextServiceList = RECORD
  208.         fTextServiceCount:        INTEGER;                                { number of entries in the 'fServices' array }
  209.         fServices:                ARRAY [0..0] OF TextServiceInfo;        { Note: array of 'TextServiceInfo' records follows }
  210.     END;
  211.  
  212.     TextServiceListPtr = ^TextServiceList;
  213.  
  214.     TextServiceListHandle = ^TextServiceListPtr;
  215.  
  216.     ScriptLanguageRecord = RECORD
  217.         fScript:                ScriptCode;
  218.         fLanguage:                LangCode;
  219.     END;
  220.  
  221.     ScriptLanguageSupport = RECORD
  222.         fScriptLanguageCount:    INTEGER;                                { number of entries in the 'fScriptLanguageArray' array }
  223.         fScriptLanguageArray:    ARRAY [0..0] OF ScriptLanguageRecord;    { Note: array of 'ScriptLanguageRecord' records follows }
  224.     END;
  225.  
  226.     ScriptLanguageSupportPtr = ^ScriptLanguageSupport;
  227.  
  228.     ScriptLanguageSupportHandle = ^ScriptLanguageSupportPtr;
  229.  
  230.  
  231. FUNCTION NewTSMDocument(numOfInterface: INTEGER; VAR supportedInterfaceTypes: InterfaceTypeList; VAR idocID: TSMDocumentID; refcon: LONGINT): OSErr;
  232.     {$IFC NOT GENERATINGCFM}
  233.     INLINE $7000, $AA54;
  234.     {$ENDC}
  235. FUNCTION DeleteTSMDocument(idocID: TSMDocumentID): OSErr;
  236.     {$IFC NOT GENERATINGCFM}
  237.     INLINE $7001, $AA54;
  238.     {$ENDC}
  239. FUNCTION ActivateTSMDocument(idocID: TSMDocumentID): OSErr;
  240.     {$IFC NOT GENERATINGCFM}
  241.     INLINE $7002, $AA54;
  242.     {$ENDC}
  243. FUNCTION DeactivateTSMDocument(idocID: TSMDocumentID): OSErr;
  244.     {$IFC NOT GENERATINGCFM}
  245.     INLINE $7003, $AA54;
  246.     {$ENDC}
  247. FUNCTION TSMEvent(VAR event: EventRecord): BOOLEAN;
  248.     {$IFC NOT GENERATINGCFM}
  249.     INLINE $7004, $AA54;
  250.     {$ENDC}
  251. FUNCTION TSMMenuSelect(menuResult: LONGINT): BOOLEAN;
  252.     {$IFC NOT GENERATINGCFM}
  253.     INLINE $7005, $AA54;
  254.     {$ENDC}
  255. FUNCTION SetTSMCursor(mousePos: Point): BOOLEAN;
  256.     {$IFC NOT GENERATINGCFM}
  257.     INLINE $7006, $AA54;
  258.     {$ENDC}
  259. FUNCTION FixTSMDocument(idocID: TSMDocumentID): OSErr;
  260.     {$IFC NOT GENERATINGCFM}
  261.     INLINE $7007, $AA54;
  262.     {$ENDC}
  263. FUNCTION GetServiceList(numOfInterface: INTEGER; VAR supportedInterfaceTypes: OSType; VAR serviceInfo: TextServiceListHandle; VAR seedValue: LONGINT): OSErr;
  264.     {$IFC NOT GENERATINGCFM}
  265.     INLINE $7008, $AA54;
  266.     {$ENDC}
  267. FUNCTION OpenTextService(idocID: TSMDocumentID; aComponent: Component; VAR aComponentInstance: ComponentInstance): OSErr;
  268.     {$IFC NOT GENERATINGCFM}
  269.     INLINE $7009, $AA54;
  270.     {$ENDC}
  271. FUNCTION CloseTextService(idocID: TSMDocumentID; aComponentInstance: ComponentInstance): OSErr;
  272.     {$IFC NOT GENERATINGCFM}
  273.     INLINE $700A, $AA54;
  274.     {$ENDC}
  275. FUNCTION SendAEFromTSMComponent({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP): OSErr;
  276.     {$IFC NOT GENERATINGCFM}
  277.     INLINE $700B, $AA54;
  278.     {$ENDC}
  279. FUNCTION InitTSMAwareApplication: OSErr;
  280.     {$IFC NOT GENERATINGCFM}
  281.     INLINE $7014, $AA54;
  282.     {$ENDC}
  283. FUNCTION CloseTSMAwareApplication: OSErr;
  284.     {$IFC NOT GENERATINGCFM}
  285.     INLINE $7015, $AA54;
  286.     {$ENDC}
  287. { Utilities }
  288. FUNCTION SetDefaultInputMethod(ts: Component; VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  289.     {$IFC NOT GENERATINGCFM}
  290.     INLINE $700C, $AA54;
  291.     {$ENDC}
  292. FUNCTION GetDefaultInputMethod(VAR ts: Component; VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  293.     {$IFC NOT GENERATINGCFM}
  294.     INLINE $700D, $AA54;
  295.     {$ENDC}
  296. FUNCTION SetTextServiceLanguage(VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $700E, $AA54;
  299.     {$ENDC}
  300. FUNCTION GetTextServiceLanguage(VAR slRecordPtr: ScriptLanguageRecord): OSErr;
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $700F, $AA54;
  303.     {$ENDC}
  304. FUNCTION UseInputWindow(idocID: TSMDocumentID; useWindow: BOOLEAN): OSErr;
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $7010, $AA54;
  307.     {$ENDC}
  308. FUNCTION NewServiceWindow(wStorage: UNIV Ptr; {CONST}VAR boundsRect: Rect; title: ConstStr255Param; visible: BOOLEAN; theProc: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; ts: ComponentInstance; VAR window: WindowPtr): OSErr;
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $7011, $AA54;
  311.     {$ENDC}
  312. FUNCTION CloseServiceWindow(window: WindowPtr): OSErr;
  313.     {$IFC NOT GENERATINGCFM}
  314.     INLINE $7012, $AA54;
  315.     {$ENDC}
  316. FUNCTION GetFrontServiceWindow(VAR window: WindowPtr): OSErr;
  317.     {$IFC NOT GENERATINGCFM}
  318.     INLINE $7013, $AA54;
  319.     {$ENDC}
  320. FUNCTION FindServiceWindow(thePoint: Point; VAR theWindow: WindowPtr): INTEGER;
  321.     {$IFC NOT GENERATINGCFM}
  322.     INLINE $7017, $AA54;
  323.     {$ENDC}
  324. { Low level TSM routines }
  325. FUNCTION GetScriptLanguageSupport(ts: ComponentInstance; VAR scriptHdl: ScriptLanguageSupportHandle): ComponentResult;
  326.     {$IFC NOT GENERATINGCFM}
  327.     INLINE $2F3C, $04, $0001, $7000, $A82A;
  328.     {$ENDC}
  329. FUNCTION InitiateTextService(ts: ComponentInstance): ComponentResult;
  330.     {$IFC NOT GENERATINGCFM}
  331.     INLINE $2F3C, $00, $0002, $7000, $A82A;
  332.     {$ENDC}
  333. FUNCTION TerminateTextService(ts: ComponentInstance): ComponentResult;
  334.     {$IFC NOT GENERATINGCFM}
  335.     INLINE $2F3C, $00, $0003, $7000, $A82A;
  336.     {$ENDC}
  337. FUNCTION ActivateTextService(ts: ComponentInstance): ComponentResult;
  338.     {$IFC NOT GENERATINGCFM}
  339.     INLINE $2F3C, $00, $0004, $7000, $A82A;
  340.     {$ENDC}
  341. FUNCTION DeactivateTextService(ts: ComponentInstance): ComponentResult;
  342.     {$IFC NOT GENERATINGCFM}
  343.     INLINE $2F3C, $00, $0005, $7000, $A82A;
  344.     {$ENDC}
  345. FUNCTION TextServiceEvent(ts: ComponentInstance; numOfEvents: INTEGER; VAR event: EventRecord): ComponentResult;
  346.     {$IFC NOT GENERATINGCFM}
  347.     INLINE $2F3C, $06, $0006, $7000, $A82A;
  348.     {$ENDC}
  349. FUNCTION GetTextServiceMenu(ts: ComponentInstance; VAR serviceMenu: MenuHandle): ComponentResult;
  350.     {$IFC NOT GENERATINGCFM}
  351.     INLINE $2F3C, $4, $0007, $7000, $A82A;
  352.     {$ENDC}
  353. FUNCTION TextServiceMenuSelect(ts: ComponentInstance; serviceMenu: MenuHandle; item: INTEGER): ComponentResult;
  354.     {$IFC NOT GENERATINGCFM}
  355.     INLINE $2F3C, $06, $0008, $7000, $A82A;
  356.     {$ENDC}
  357. FUNCTION FixTextService(ts: ComponentInstance): ComponentResult;
  358.     {$IFC NOT GENERATINGCFM}
  359.     INLINE $2F3C, $00, $0009, $7000, $A82A;
  360.     {$ENDC}
  361. FUNCTION SetTextServiceCursor(ts: ComponentInstance; mousePos: Point): ComponentResult;
  362.     {$IFC NOT GENERATINGCFM}
  363.     INLINE $2F3C, $04, $000A, $7000, $A82A;
  364.     {$ENDC}
  365. FUNCTION HidePaletteWindows(ts: ComponentInstance): ComponentResult;
  366.     {$IFC NOT GENERATINGCFM}
  367.     INLINE $2F3C, $00, $000B, $7000, $A82A;
  368.     {$ENDC}
  369.  
  370. {$ALIGN RESET}
  371. {$POP}
  372.  
  373. {$SETC UsingIncludes := TextServicesIncludes}
  374.  
  375. {$ENDC} {__TEXTSERVICES__}
  376.  
  377. {$IFC NOT UsingIncludes}
  378.  END.
  379. {$ENDC}
  380.